package com.roadjava.rbac.bean.vo;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.StrUtil;
import com.roadjava.rbac.constants.CommonConstants;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Collections;
import java.util.List;


@Data
@EqualsAndHashCode(callSuper = true)
public class AuthorityVO extends SortableTreeNode<AuthorityVO> {
    /**
     * @see com.roadjava.rbac.enums.AuthorityTypeEnum
     */
    private Integer type;

    /**
     * 权限名称,可用于标题和菜单名称
     */
    private String authorityName;
    /**
     * 前端路由路径
     */
    private String path;

    /**
     * 关联的后端请求,多个通过,分隔
     */
    private String relateBackUris;

    /**
     * relateBackUris转为List
     */
    private List<String> relateBackUriList;

    /**
     * 前端组件相对@/views/所在的目录,如dept/DeptManage
     */
    private String componentPath;
    /**
     * 0:否1:是
     */
    private Integer showInMenu;
    /**
     * 菜单对应的图标名称
     */
    private String icon;

    public List<String> getRelateBackUriList() {
        if (StrUtil.isBlank(relateBackUris)) {
            return Collections.emptyList();
        }
        return ListUtil.toList(relateBackUris.split(CommonConstants.COMMA));
    }
}
